package com.itheima.test.TCP.normaltest;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Service {//TCP接收端
    public static void main(String[] args) throws IOException {
        //创建ServerSocket对象,参数为端口号
        ServerSocket serverSocket = new ServerSocket(10000);
        //等待客户连接
        Socket socket = serverSocket.accept();
        //获得输入流对象
        InputStream inputStream = socket.getInputStream();
        //输出数据
        int ch;
        while((ch=inputStream.read())!=-1){
            System.out.print((char) ch);//打印数据
        }
        //释放资源
        inputStream.close();
        socket.close();
        serverSocket.close();
    }
}
